//容量为m的小根堆 比堆顶大就压入
#include <cstdio>
#include <algorithm>
#include <functional>
using namespace std;
#define DEBUG
const int N=1010;
int m, n;
int a[N];
int main()
{
    #ifdef DEBUG
        freopen("./in.txt", "r", stdin);
        freopen("./out.txt", "w", stdout);
    #endif
    scanf("%d%d", &n, &m);
    for(int i=1; i<=n; i++)
    {
        scanf("%d", &a[i]);
    }
    
    sort(a+1, a+1+n, greater<int>());
    printf("%d\n", a[m]);
    return 0;
}